﻿using System.Collections.Generic;
using System.Linq;


namespace RaceList.activity.help
{
    /// <summary>
    ///     这里主要是封装了一些数据库中对Activity_Relay,Activity_SubRelay的操作
    /// </summary>
    public partial class RelayQuery
    {
        public static Activity_Awards GetActivity_Awards()
        {
            ipowdb_suibian_webDataContext db = ConnHelper.ipowdb_suibian_web();
            Activity_Awards award =
                db.Activity_Awards.FirstOrDefault();
            return award;
        }
        public static Activity_Awards GetActivity_Awards(int awardId)
        {
            ipowdb_suibian_webDataContext db = ConnHelper.ipowdb_suibian_web();
            Activity_Awards award =
                db.Activity_Awards.Where(s => s.Id == awardId && s.status && s.isDel == false).FirstOrDefault();
            return award;
        }

        public static List<Activity_Awards> GetActivity_AwardsByRelay(int cycleId)
        {
            ipowdb_suibian_webDataContext db = ConnHelper.ipowdb_suibian_web();
            List<Activity_Awards> list =
                db.Activity_Awards.Where(s => s.cycleId == cycleId && s.status && s.isDel == false).ToList();
            return list;
        }

        public static List<Activity_Awards> GetActivity_Awards(int? sponsorId)
        {
            ipowdb_suibian_webDataContext db = ConnHelper.ipowdb_suibian_web();
            List<Activity_Awards> list = db.Activity_Awards.Where(s => s.status && s.isDel == false).ToList();

            if (sponsorId.HasValue)
                list = db.Activity_Awards.Where(s => s.sponsorId == sponsorId).ToList();
            else
                list = db.Activity_Awards.Where(s => s.sponsorId == null).ToList();
            return list;
        }
    }
}